<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //new 过程  
        //1.执行函数
        //2.函数中创建一个空对象
        //3.将空对象的原型设置为函数的原型
        //4.将this指向空对象
        //5.return 的原理


        function Foo() {
            //{a : function()}.__proto__ = {a : function}
            console.log(this) //{}
            console.log(this.a())
            this.a = function () {
                console.log(1)
            }
            return {
                a: function () {
                    console.log(2)
                }
            }
        }
        Foo.a = function () {
            console.log(3)
        }
        Foo.prototype.a = function () {
            console.log(4)
            //return undefined
        }
        Foo.a()
        var obj = new Foo()
        obj.a()


        //3 {}  4  undefined  2




    </script>
</body>

</html>